﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using RooHui.Infrastructure.Entities.EFContext;
using RooHui.Infrastructure.Entities.Repository;

namespace RooHui.Infrastructure.Entities.Entity
{
    public class Configration : IAccessible<S_Configration, Configration>, ILogicEntity<S_Configration, Configration>
    {
        public int ID { get; set; }
        public string Key { get; set; }
        public string Value { get; set; }
        public string Comment { get; set; }
        public DateTime RecordDate { get; set; }
        public int Type { get; set; }

        protected override void Covariant(S_Configration model)
        {
            if (model != null)
            {
                this.Comment = model.Comment;
                this.ID = model.ID;
                this.Key = model.Key;
                this.RecordDate = model.RecordDate;
                this.Type = model.Type;
                this.Value = model.Value;
            }
        }

        protected override S_Configration Inverter(Configration model)
        {
            if (model != null)
            {
                return new S_Configration()
                {
                    Comment = model.Comment,
                    ID = model.ID,
                    Key = model.Key,
                    RecordDate = model.RecordDate,
                    Type = model.Type,
                    Value = model.Value
                };
            }
            return null;
        }

        public Configration Set(S_Configration dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
